package 并发编程16.实际运用场景;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.DelayQueue;

/**
 * @author idea
 * @data 2019/2/10
 */
public class EndExam extends Student {

    private DelayQueue<Student> students;

    private CountDownLatch countDownLatch;

    private Thread teacherThread;


    public EndExam(DelayQueue<Student> students, long workTime, CountDownLatch countDownLatch,Thread teacherThread) {
        super("强制收卷", workTime,countDownLatch);
        this.students = students;
        this.countDownLatch = countDownLatch;
        this.teacherThread = teacherThread;
    }



    @Override
    public void run() {
        super.run();
        teacherThread.interrupt();
        Student student;
        for (Student student1 : students) {
            student1.setForce(true);
            student1.run();
        }
        countDownLatch.countDown();
    }
}
